package com.dahouzi.web.article;

import javax.annotation.security.PermitAll;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.dahouzi.dao.entity.TArticle;
import com.dahouzi.service.TArticleService;

@Controller
@PermitAll
@RequestMapping("/ArticleCtrl")
public class ArticleCtrl {

	@Autowired
	private TArticleService tArticleService;

	/**
	 * 目录
	 *
	 * @author 空空dream
	 * @date 2017年10月4日
	 */
	@RequestMapping("/catalog")
	public String catalog(ModelMap map) {
		Page<TArticle> article = tArticleService.selectPage(new Page<TArticle>(1, 15), new EntityWrapper<TArticle>());
		map.addAttribute("page", article);
		return "table/article/catalog";
	}

	@RequestMapping("/article")
	public String article(ModelMap map, TArticle article) {
		map.addAttribute("article", tArticleService.selectById(article.getId()));
		return "table/article/article";
	}

}
